<?php

function __autoload($class_name) 
{
    $filename = strtolower($class_name) . '.class.php';
    $file = '../model/' . $filename;
    
    if ( file_exists($file) == false ){
        return false;
    }
    include($file);
}

class TestEngine
{
    private $counter = 0;
    private $passed = 0;
    private $failed = 0;
    
    function __construct()
    {
        $this->counter = 0;
        $this->passed  = 0;
        $this->failed  = 0;
    }
    
    /**
     * log a message
     */
    private function log($str)
    {
        echo "[  LOG  ] " . $str . "<br />";
    }
    
    /**
     * log a error
     */
    private function error($str)
    {
        echo "[ ERROR ] " . $str . "<br />";
    }
    
    /**
     * log
     */
     private function success($str)
    {
        echo "[SUCCESS] ". $str . "<br />";        
    }
    
    private function passed($id)
    {
        echo "<b>[ Test ". $id . " ]</b> PASSED !<br />";    
    }
    
    private function failed($id, $testcase)
    {
        echo "<b>[ Test ". $id . " ] FAILED !</b><br />";
        echo "<---------------------------<br />";    
        echo $testcase . "<br />";
        echo "---------------------------><br />"; 
    }
    
    
    /**
     * checking
     */
    public function checkValue($checkValue, $needValue)
    {
        $this->counter++;
        if($checkValue == $needValue){
            $this->passed($this->counter);
            $this->passed++;
        }
        else {
            $this->failed($this->counter, $checkValue . " != " . $needValue);
            $this->failed++;
        }
    }
    
    public function checkMessage($checkMess, $needMess)
    {
        $this->counter++;
        echo "<b>[ Test ". $this->counter . " ]</b>[PASS IF] " . $checkMess . " == " . $needMess . "<br />";
    }
    
    public function total()
    {
    	
        echo "[ TOTAL ] Passed " . $this->passed . "/" . $this->counter . "(didn't include 'pass if') <br />";
        $this->__construct();
    }
}

?>